<template>
  <common-table
    ref="tableRef"
    class="source-list-table"
    :fetch="api"
    :fetch-params="apiParams"
    :showToolbar="false"
    :columns="columns"
    :pagination="false"
  >
  </common-table>
</template>

<script>
import CommonTable from '@gis/lib/components/vex-table/index.vue';
import areaCodeMixin from '@gis/lib/mixins/areaCodeMixin.js';
import { dialog } from '@gis/lib/components/antd-dialog';
import { getGisEntityList } from '@gis/lib/api';

export default {
  name: 'source-list-table',
  components: { CommonTable },
  mixins: [areaCodeMixin],
  data() {
    return {
      columns: [
        {
          title: '名称',
          dataIndex: 'name',
          width: 100,
        },
        {
          title: '地址',
          dataIndex: 'address',
        },
        {
          title: '类型',
          dataIndex: 'type_name',
          width: 60,
          align: 'center',
          // customRender: () => "设备",
        },
        // {
        //   title: "操作",
        //   dataIndex: "action",
        //   width: 100,
        //   align: "center",
        //   scopedSlots: { customRender: "action" },
        // },
      ],
    };
  },
  mounted() {
    this.$refs.tableRef.load();
  },
  methods: {
    async api(params = {}) {
      params.type = 2;
      const res = await getGisEntityList(params).catch(() => {});
      const data = res ? res.data || [] : [];
      return { data: data, total: data.length };
    },
    showVideo(data) {
      // console.log(data);
      dialog({
        content: () => import('./marker-info-window.vue'),
        contentProps: {
          url: () => import('@gis/lib/components/player/TslNvrPlayer/index.vue'),
          options: { code: data.identification, name: data.name },
        },
        dialogProps: {
          title: data.name,
          width: '1000px',
          movable: true,
        },
      });
    },
  },
};
</script>

<style scoped lang="less">
.source-list-table {
  height: 100%;
}
</style>
